package com.cqjtu.eecs.controller;


import com.cqjtu.eecs.entity.dto.MajorBriefDTO;
import com.cqjtu.eecs.entity.vo.MajorBriefVO;
import com.cqjtu.eecs.exception.ParamsErrorException;
import com.cqjtu.eecs.service.ITrainingProjectService;
import com.cqjtu.eecs.utils.Assert;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author   luojun
 * @since 2022-02-28
 */
@RestController
@RequestMapping("/training-project")
@Api(tags = "培养方案接口")
public class TrainingProjectController {
    private final ITrainingProjectService trainingProjectService;

    public TrainingProjectController(ITrainingProjectService trainingProjectService) {
        this.trainingProjectService = trainingProjectService;
    }

    @ApiOperation("通过专业代码获取专业培养方案模板一")
    @GetMapping("/getTrainingProjectByMajorCode/{id}")
    public MajorBriefVO getTrainingProjectVO(@PathVariable("id") String id){
        Assert.notNull(id, new ParamsErrorException("参数异常"));
        MajorBriefDTO trainingProjectDTO = trainingProjectService.getTrainingProjectDTO(id);
        MajorBriefVO majorBriefVO = new MajorBriefVO();
        BeanUtils.copyProperties(trainingProjectDTO, majorBriefVO);
        return majorBriefVO;
    }
}
